[<<Previous Entry]
[^^Up^^]
[Next Entry>>]
[Menu]
[About The Guide]
putimage() Restore Saved Screen Image
#include <graphics.h>
void far putimage(left,top,bitmap,op);
int left;
int top;
void far *bitmap;
int op;
putimage() puts a previously-saved bit image back onto the screen.
The coordinates ('left','top') are used to place the image on the
screen. 'bitmap' refers to the area in memory where the image has
been stored (using getimage()). 'op' determines how the color for
each destination pixel is computed. This is based on the pixel
already on the screen and the source pixel in memory. These operators
(enumeration 'putimage_ops') are defined in <graphics.h> as:
Name Value Description
COPY_PUT 0 Copy source bitmap image
XOR_PUT 1 Exclusive-or source image with that on
the screen
OR_PUT 2 Inclusive-or source image with that on
the screen
AND_PUT 3 And source image with that on the screen
NOT_PUT 4 Copy inverse of the source image
Returns: Nothing.
-------------------------------- Example ---------------------------------
The following statements create a rectangular area on the screen
which is to be saved. The amount of memory needed to save it is
determined and space is allocated for it. The area is saved, then
cleared and a message is written where the rectangle existed. The
original rectangle is then restored in each of the five modes. The
area in memory is then deallocated.
#include <graphics.h>
int gdriver = DETECT;
int gmode;
main()
{
void *pict;
unsigned p_size;
int l = 100, t = 100, r = 300, b = 300;
int x;
initgraph(&gdriver,&gmode,"");
setfillstyle(HATCH_FILL,RED);
rectangle(l,t,r,b);
floodfill(l+10,t+10,WHITE);
outtextxy(l+50,t+100,"ORIGINAL SCREEN");
getch();
p_size = imagesize(l,t,r,b);
pict = malloc(p_size);
getimage(l,t,r,b,pict);
cleardevice();
rectangle(l,t,r,b);
outtextxy(l+50,t+100,"SCREEN SAVED,");
outtextxy(l+50,t+110,"THEN CLEARED");
getch();
for (x = 0; x < 5; x++) {
putimage(l,t,pict,x);
outtextxy(l+50,t+110," (RESTORED)");
getch();
cleardevice();
}
free(pict);
closegraph();
}
See Also:
getimage()
putimage()
This page created by ng2html v1.05, the Norton guide to HTML conversion utility.
Written by Dave Pearson